from gui.window_gui import WindowGui
from model.exception import ParkTokenFatalError, ParkTokenWechatHwndError
from myutils.window_helper import *


class WechatGui(WindowGui):
    def __init__(self):
        super().__init__()

    def check_env(self):
        super().check_env()
        if not is_valid_wechat_window(self.hwnd):
            raise ParkTokenWechatHwndError("不是有效的微信窗口")

    def close_wechat_browser(self):
        """关闭微信浏览器"""
        close_window(finw_window_hwnd_list_by_classname("CefWebViewWnd"))
        close_window(finw_window_hwnd_list_by_classname("Chrome_WidgetWin_0"))
        # kill_process_by_name("WeChatAppEx.exe")
